import request from '@/plugin/axios'

export function getResource (data) {
  return request({
    url: '/v1/roles/get_resource',
    method: 'get',
    data
  })
}
export function setUser (data) {
  return request({
    url: '/v1/roles/set_user',
    method: 'post',
    data
  })
}
export function getUser (data) {
  return request({
    url: '/v1/roles/get_user',
    method: 'get',
    data
  })
}
export function setResource (data) {
  return request({
    url: '/v1/roles/set_resource',
    method: 'post',
    data
  })
}
export function roleUser (data) {
  return request({
    url: '/v1/role_user',
    method: 'get',
    params: data
  })
}
export function roleResource (data) {
  return request({
    url: '/v1/role_resource',
    method: 'get',
    params: data
  })
}
export function resource (data) {
  return request({
    url: '/v1/resource',
    method: 'get',
    data
  })
}
export function role (data) {
  return request({
    url: '/v1/role',
    method: 'get',
    data
  })
}

// 获取当前用户
export const roleList = data => {
  // return request(`/api/v1/role?pageNum=${pageNum}&pageSize=${PAGE_SIZE}&${whereStr}`)
  return request({
    url: '/v1/role',
    method: 'get',
    params: data
  })
}

// 创建用户
export const createRole = data => {
  return request({
    url: '/v1/role',
    method: 'post',
    data
  })
}

// 修改用户
export const updateRole = data => {
  return request({
    url: `/v1/role/${data.id}`,
    method: 'put',
    data
  })
}

// 删除用户
export const delRole = data => {
  return request({
    url: `/v1/role/${data.id}`,
    method: 'delete',
    data
  })
}

// 批量删除用户
export const delAll = data => {
  return request({
    url: `/v1/role/${data.id[0]}`,
    method: 'delete',
    data
  })
}
